
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml" lang="zh_CN">
  <head>
    <meta charset="utf-8" />
    <title>bytes 对象 &#8212; Python 3.7.8 文档</title>
    <link rel="stylesheet" href="../_static/pydoctheme.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    
    <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/underscore.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <script type="text/javascript" src="../_static/language_data.js"></script>
    <script type="text/javascript" src="../_static/translations.js"></script>
    
    <script type="text/javascript" src="../_static/sidebar.js"></script>
    
    <link rel="search" type="application/opensearchdescription+xml"
          title="在 Python 3.7.8 文档 中搜索"
          href="../_static/opensearch.xml"/>
    <link rel="author" title="关于这些文档" href="../about.html" />
    <link rel="index" title="索引" href="../genindex.html" />
    <link rel="search" title="搜索" href="../search.html" />
    <link rel="copyright" title="版权所有" href="../copyright.html" />
    <link rel="next" title="字节数组对象" href="bytearray.html" />
    <link rel="prev" title="复数对象" href="complex.html" />
    <link rel="shortcut icon" type="image/png" href="../_static/py.png" />
    <link rel="canonical" href="https://docs.python.org/3/c-api/bytes.html" />
    
    <script type="text/javascript" src="../_static/copybutton.js"></script>
    
    
    
    
    <style>
      @media only screen {
        table.full-width-table {
            width: 100%;
        }
      }
    </style>
 

  </head><body>
  
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>导航</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="总目录"
             accesskey="I">索引</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python 模块索引"
             >模块</a> |</li>
        <li class="right" >
          <a href="bytearray.html" title="字节数组对象"
             accesskey="N">下一页</a> |</li>
        <li class="right" >
          <a href="complex.html" title="复数对象"
             accesskey="P">上一页</a> |</li>
        <li><img src="../_static/py.png" alt=""
                 style="vertical-align: middle; margin-top: -1px"/></li>
        <li><a href="https://www.python.org/">Python</a> &#187;</li>
        <li>
          <a href="../index.html">3.7.8 Documentation</a> &#187;
        </li>

          <li class="nav-item nav-item-1"><a href="index.html" >Python/C API 参考手册</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="concrete.html" accesskey="U">具体的对象层</a> &#187;</li>
    <li class="right">
        

    <div class="inline-search" style="display: none" role="search">
        <form class="inline-search" action="../search.html" method="get">
          <input placeholder="快速搜索" type="text" name="q" />
          <input type="submit" value="转向" />
          <input type="hidden" name="check_keywords" value="yes" />
          <input type="hidden" name="area" value="default" />
        </form>
    </div>
    <script type="text/javascript">$('.inline-search').show(0);</script>
         |
    </li>

      </ul>
    </div>    

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <div class="section" id="bytes-objects">
<span id="bytesobjects"></span><h1>bytes 对象<a class="headerlink" href="#bytes-objects" title="永久链接至标题">¶</a></h1>
<p>当期望带一个字节串形参但却带一个非字节串形参被调用时，这些函数会引发 <a class="reference internal" href="../library/exceptions.html#TypeError" title="TypeError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">TypeError</span></code></a>。</p>
<span class="target" id="index-0"></span><dl class="type">
<dt id="c.PyBytesObject">
<code class="sig-name descname">PyBytesObject</code><a class="headerlink" href="#c.PyBytesObject" title="永久链接至目标">¶</a></dt>
<dd><p>这种 <a class="reference internal" href="structures.html#c.PyObject" title="PyObject"><code class="xref c c-type docutils literal notranslate"><span class="pre">PyObject</span></code></a> 的子类型表示一个 Python 字节对象。</p>
</dd></dl>

<dl class="var">
<dt id="c.PyBytes_Type">
<a class="reference internal" href="type.html#c.PyTypeObject" title="PyTypeObject">PyTypeObject</a> <code class="sig-name descname">PyBytes_Type</code><a class="headerlink" href="#c.PyBytes_Type" title="永久链接至目标">¶</a></dt>
<dd><p><a class="reference internal" href="type.html#c.PyTypeObject" title="PyTypeObject"><code class="xref c c-type docutils literal notranslate"><span class="pre">PyTypeObject</span></code></a> 的实例代表一个 Python 字节类型，在 Python 层面它与 <a class="reference internal" href="../library/stdtypes.html#bytes" title="bytes"><code class="xref py py-class docutils literal notranslate"><span class="pre">bytes</span></code></a> 是相同的对象。</p>
</dd></dl>

<dl class="function">
<dt id="c.PyBytes_Check">
int <code class="sig-name descname">PyBytes_Check</code><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a><em> *o</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyBytes_Check" title="永久链接至目标">¶</a></dt>
<dd><p>如果对象 <em>o</em> 是字节对象或字节类型的子类型的实例，则返回 true。</p>
</dd></dl>

<dl class="function">
<dt id="c.PyBytes_CheckExact">
int <code class="sig-name descname">PyBytes_CheckExact</code><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a><em> *o</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyBytes_CheckExact" title="永久链接至目标">¶</a></dt>
<dd><p>如果对象 <em>o</em> 是字节对象，但不是字节类型子类型的实例，则返回 true。</p>
</dd></dl>

<dl class="function">
<dt id="c.PyBytes_FromString">
<a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a>* <code class="sig-name descname">PyBytes_FromString</code><span class="sig-paren">(</span>const char<em> *v</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyBytes_FromString" title="永久链接至目标">¶</a></dt>
<dd><em class="refcount">Return value: New reference.</em><p>成功时返回一个以字符串 <em>v</em> 的副本为值的新字节串对象，失败时返回 <code class="docutils literal notranslate"><span class="pre">NULL</span></code>。 形参 <em>v</em> 不可为 <code class="docutils literal notranslate"><span class="pre">NULL</span></code>；它不会被检查。</p>
</dd></dl>

<dl class="function">
<dt id="c.PyBytes_FromStringAndSize">
<a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a>* <code class="sig-name descname">PyBytes_FromStringAndSize</code><span class="sig-paren">(</span>const char<em> *v</em>, Py_ssize_t<em> len</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyBytes_FromStringAndSize" title="永久链接至目标">¶</a></dt>
<dd><em class="refcount">Return value: New reference.</em><p>成功时返回一个以字符串 <em>v</em> 的副本为值且长度为 <em>len</em> 的新字节串对象，失败时返回 <code class="docutils literal notranslate"><span class="pre">NULL</span></code>。 如果 <em>v</em> 为 <code class="docutils literal notranslate"><span class="pre">NULL</span></code>，则不初始化字节串对象的内容。</p>
</dd></dl>

<dl class="function">
<dt id="c.PyBytes_FromFormat">
<a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a>* <code class="sig-name descname">PyBytes_FromFormat</code><span class="sig-paren">(</span>const char<em> *format</em>, ...<span class="sig-paren">)</span><a class="headerlink" href="#c.PyBytes_FromFormat" title="永久链接至目标">¶</a></dt>
<dd><em class="refcount">Return value: New reference.</em><p>接受一个 C <code class="xref c c-func docutils literal notranslate"><span class="pre">printf()</span></code> 风格的 <em>format</em> 字符串和可变数量的参数，计算结果 Python 字节串对象的大小并返回参数值经格式化后的字节串对象。 可变数量的参数必须均为 C 类型并且必须恰好与 <em>format</em> 字符串中的格式字符相对应。 允许使用下列格式字符串:</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 29%" />
<col style="width: 23%" />
<col style="width: 48%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>格式字符</p></th>
<th class="head"><p>类型</p></th>
<th class="head"><p>注释</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p><code class="xref py py-attr docutils literal notranslate"><span class="pre">%%</span></code></p></td>
<td><p><em>不适用</em></p></td>
<td><p>文字%字符。</p></td>
</tr>
<tr class="row-odd"><td><p><code class="xref py py-attr docutils literal notranslate"><span class="pre">%c</span></code></p></td>
<td><p>整型</p></td>
<td><p>一个字节，被表示为一个 C 语言的整型</p></td>
</tr>
<tr class="row-even"><td><p><code class="xref py py-attr docutils literal notranslate"><span class="pre">%d</span></code></p></td>
<td><p>整型</p></td>
<td><p>相当于 <code class="docutils literal notranslate"><span class="pre">printf(&quot;%d&quot;)</span></code>. <a class="footnote-reference brackets" href="#id9" id="id1">1</a></p></td>
</tr>
<tr class="row-odd"><td><p><code class="xref py py-attr docutils literal notranslate"><span class="pre">%u</span></code></p></td>
<td><p>无符号整型</p></td>
<td><p>相当于 <code class="docutils literal notranslate"><span class="pre">printf(&quot;%u&quot;)</span></code>. <a class="footnote-reference brackets" href="#id9" id="id2">1</a></p></td>
</tr>
<tr class="row-even"><td><p><code class="xref py py-attr docutils literal notranslate"><span class="pre">%ld</span></code></p></td>
<td><p>长整型</p></td>
<td><p>相当于 <code class="docutils literal notranslate"><span class="pre">printf(&quot;%ld&quot;)</span></code>. <a class="footnote-reference brackets" href="#id9" id="id3">1</a></p></td>
</tr>
<tr class="row-odd"><td><p><code class="xref py py-attr docutils literal notranslate"><span class="pre">%lu</span></code></p></td>
<td><p>无符号长整型</p></td>
<td><p>相当于 <code class="docutils literal notranslate"><span class="pre">printf(&quot;%lu&quot;)</span></code>. <a class="footnote-reference brackets" href="#id9" id="id4">1</a></p></td>
</tr>
<tr class="row-even"><td><p><code class="xref py py-attr docutils literal notranslate"><span class="pre">%zd</span></code></p></td>
<td><p>Py_ssize_t</p></td>
<td><p>相当于 <code class="docutils literal notranslate"><span class="pre">printf(&quot;%zd&quot;)</span></code>. <a class="footnote-reference brackets" href="#id9" id="id5">1</a></p></td>
</tr>
<tr class="row-odd"><td><p><code class="xref py py-attr docutils literal notranslate"><span class="pre">%zu</span></code></p></td>
<td><p>size_t</p></td>
<td><p>相当于 <code class="docutils literal notranslate"><span class="pre">printf(&quot;%zu&quot;)</span></code>. <a class="footnote-reference brackets" href="#id9" id="id6">1</a></p></td>
</tr>
<tr class="row-even"><td><p><code class="xref py py-attr docutils literal notranslate"><span class="pre">%i</span></code></p></td>
<td><p>整型</p></td>
<td><p>相当于 <code class="docutils literal notranslate"><span class="pre">printf(&quot;%i&quot;)</span></code>. <a class="footnote-reference brackets" href="#id9" id="id7">1</a></p></td>
</tr>
<tr class="row-odd"><td><p><code class="xref py py-attr docutils literal notranslate"><span class="pre">%x</span></code></p></td>
<td><p>整型</p></td>
<td><p>相当于 <code class="docutils literal notranslate"><span class="pre">printf(&quot;%x&quot;)</span></code>. <a class="footnote-reference brackets" href="#id9" id="id8">1</a></p></td>
</tr>
<tr class="row-even"><td><p><code class="xref py py-attr docutils literal notranslate"><span class="pre">%s</span></code></p></td>
<td><p>const char*</p></td>
<td><p>以 null 为终止符的 C 字符数组。</p></td>
</tr>
<tr class="row-odd"><td><p><code class="xref py py-attr docutils literal notranslate"><span class="pre">%p</span></code></p></td>
<td><p>const void*</p></td>
<td><p>一个 C 指针的十六进制表示形式。 基本等价于 <code class="docutils literal notranslate"><span class="pre">printf(&quot;%p&quot;)</span></code> 但它会确保以字面值 <code class="docutils literal notranslate"><span class="pre">0x</span></code> 开头，不论系统平台上 <code class="docutils literal notranslate"><span class="pre">printf</span></code> 的输出是什么。</p></td>
</tr>
</tbody>
</table>
<p>无法识别的格式字符会导致将格式字符串的其余所有内容原样复制到结果对象，并丢弃所有多余的参数。</p>
<dl class="footnote brackets">
<dt class="label" id="id9"><span class="brackets">1</span><span class="fn-backref">(<a href="#id1">1</a>,<a href="#id2">2</a>,<a href="#id3">3</a>,<a href="#id4">4</a>,<a href="#id5">5</a>,<a href="#id6">6</a>,<a href="#id7">7</a>,<a href="#id8">8</a>)</span></dt>
<dd><p>对于整数说明符（d，u，ld，lu，zd，zu，i，x）：当给出精度时，0 转换标志是有效的。</p>
</dd>
</dl>
</dd></dl>

<dl class="function">
<dt id="c.PyBytes_FromFormatV">
<a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a>* <code class="sig-name descname">PyBytes_FromFormatV</code><span class="sig-paren">(</span>const char<em> *format</em>, va_list<em> vargs</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyBytes_FromFormatV" title="永久链接至目标">¶</a></dt>
<dd><em class="refcount">Return value: New reference.</em><p>与 <a class="reference internal" href="#c.PyBytes_FromFormat" title="PyBytes_FromFormat"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyBytes_FromFormat()</span></code></a> 完全相同，除了它需要两个参数。</p>
</dd></dl>

<dl class="function">
<dt id="c.PyBytes_FromObject">
<a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a>* <code class="sig-name descname">PyBytes_FromObject</code><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a><em> *o</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyBytes_FromObject" title="永久链接至目标">¶</a></dt>
<dd><em class="refcount">Return value: New reference.</em><p>返回字节表示实现缓冲区协议的对象*o*。</p>
</dd></dl>

<dl class="function">
<dt id="c.PyBytes_Size">
Py_ssize_t <code class="sig-name descname">PyBytes_Size</code><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a><em> *o</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyBytes_Size" title="永久链接至目标">¶</a></dt>
<dd><p>返回字节对象*o*中字节的长度。</p>
</dd></dl>

<dl class="function">
<dt id="c.PyBytes_GET_SIZE">
Py_ssize_t <code class="sig-name descname">PyBytes_GET_SIZE</code><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a><em> *o</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyBytes_GET_SIZE" title="永久链接至目标">¶</a></dt>
<dd><p>宏版本的 <a class="reference internal" href="#c.PyBytes_Size" title="PyBytes_Size"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyBytes_Size()</span></code></a> 但是不带错误检查。</p>
</dd></dl>

<dl class="function">
<dt id="c.PyBytes_AsString">
char* <code class="sig-name descname">PyBytes_AsString</code><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a><em> *o</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyBytes_AsString" title="永久链接至目标">¶</a></dt>
<dd><p>返回对应 <em>o</em> 的内容的指针。 该指针指向 <em>o</em> 的内部缓冲区，其中包含 <code class="docutils literal notranslate"><span class="pre">len(o)</span> <span class="pre">+</span> <span class="pre">1</span></code> 个字节。 缓冲区的最后一个字节总是为空，不论是否存在其他空字节。 该数据不可通过任何形式来修改，除非是刚使用 <code class="docutils literal notranslate"><span class="pre">PyBytes_FromStringAndSize(NULL,</span> <span class="pre">size)</span></code> 创建该对象。 它不可被撤销分配。 如果 <em>o</em> 根本不是一个字节串对象，则 <a class="reference internal" href="#c.PyBytes_AsString" title="PyBytes_AsString"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyBytes_AsString()</span></code></a> 将返回 <code class="docutils literal notranslate"><span class="pre">NULL</span></code> 并引发 <a class="reference internal" href="../library/exceptions.html#TypeError" title="TypeError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">TypeError</span></code></a>。</p>
</dd></dl>

<dl class="function">
<dt id="c.PyBytes_AS_STRING">
char* <code class="sig-name descname">PyBytes_AS_STRING</code><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a><em> *string</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyBytes_AS_STRING" title="永久链接至目标">¶</a></dt>
<dd><p>宏版本的 <a class="reference internal" href="#c.PyBytes_AsString" title="PyBytes_AsString"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyBytes_AsString()</span></code></a> 但是不带错误检测。</p>
</dd></dl>

<dl class="function">
<dt id="c.PyBytes_AsStringAndSize">
int <code class="sig-name descname">PyBytes_AsStringAndSize</code><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a><em> *obj</em>, char<em> **buffer</em>, Py_ssize_t<em> *length</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyBytes_AsStringAndSize" title="永久链接至目标">¶</a></dt>
<dd><p>通过输出变量 <em>buffer</em> 和 <em>length</em> 返回以 null 为终止符的对象 <em>obj</em> 的内容。</p>
<p>如果 <em>length</em> 为 <code class="docutils literal notranslate"><span class="pre">NULL</span></code>，字节串对象就不包含嵌入的空字节；如果包含，则该函数将返回 <code class="docutils literal notranslate"><span class="pre">-1</span></code> 并引发 <a class="reference internal" href="../library/exceptions.html#ValueError" title="ValueError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ValueError</span></code></a>。</p>
<p>该缓冲区指向 <em>obj</em> 的内部缓冲，它的末尾包含一个额外的空字节（不算在 <em>length</em> 当中）。 该数据不可通过任何方式来修改，除非是刚使用 <code class="docutils literal notranslate"><span class="pre">PyBytes_FromStringAndSize(NULL,</span> <span class="pre">size)</span></code> 创建该对象。 它不可被撤销分配。 如果 <em>obj</em> 根本不是一个字节串对象，则 <a class="reference internal" href="#c.PyBytes_AsStringAndSize" title="PyBytes_AsStringAndSize"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyBytes_AsStringAndSize()</span></code></a> 将返回 <code class="docutils literal notranslate"><span class="pre">-1</span></code> 并引发 <a class="reference internal" href="../library/exceptions.html#TypeError" title="TypeError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">TypeError</span></code></a>。</p>
<div class="versionchanged">
<p><span class="versionmodified changed">在 3.5 版更改: </span>以前，当字节串对象中出现嵌入的空字节时将引发 <a class="reference internal" href="../library/exceptions.html#TypeError" title="TypeError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">TypeError</span></code></a>。</p>
</div>
</dd></dl>

<dl class="function">
<dt id="c.PyBytes_Concat">
void <code class="sig-name descname">PyBytes_Concat</code><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a><em> **bytes</em>, <a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a><em> *newpart</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyBytes_Concat" title="永久链接至目标">¶</a></dt>
<dd><p>在 <em>*bytes</em> 中创建新的字节串对象，其中包含添加到 <em>bytes</em> 的 <em>newpart</em> 的内容；调用者将获得新的引用。 对 <em>bytes</em> 原值的引用将被收回。 如果无法创建新对象，对 <em>bytes</em> 的旧引用仍将被丢弃且 <em>*bytes</em> 的值将被设为 <code class="docutils literal notranslate"><span class="pre">NULL</span></code>；并将设置适当的异常。</p>
</dd></dl>

<dl class="function">
<dt id="c.PyBytes_ConcatAndDel">
void <code class="sig-name descname">PyBytes_ConcatAndDel</code><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a><em> **bytes</em>, <a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a><em> *newpart</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyBytes_ConcatAndDel" title="永久链接至目标">¶</a></dt>
<dd><p>在 <em>*bytes</em> 中创建新的字节串对象，其中包含添加到 <em>bytes</em> 的 <em>newpart</em> 的内容。 此版本会减少 <em>newpart</em> 的引用计数。</p>
</dd></dl>

<dl class="function">
<dt id="c._PyBytes_Resize">
int <code class="sig-name descname">_PyBytes_Resize</code><span class="sig-paren">(</span><a class="reference internal" href="structures.html#c.PyObject" title="PyObject">PyObject</a><em> **bytes</em>, Py_ssize_t<em> newsize</em><span class="sig-paren">)</span><a class="headerlink" href="#c._PyBytes_Resize" title="永久链接至目标">¶</a></dt>
<dd><p>改变字节串大小的一种方式，即使其为“不可变对象”。 此方式仅用于创建全新的字节串对象；如果字节串在代码的其他部分已知则不可使用此方式。 如果输入字节串对象的引用计数不为一则调用此函数将报错。 传入一个现有字节串对象的地址作为 lvalue（它可能会被写入），并传入希望的新大小。 当成功时，<em>*bytes</em> 将存放改变大小后的字节串对象并返回 <code class="docutils literal notranslate"><span class="pre">0</span></code>；<em>*bytes</em> 中的地址可能与其输入值不同。 如果重新分配失败，则 <em>*bytes</em> 上的原字节串对象将被撤销分配，<em>*bytes</em> 会被设为 <code class="docutils literal notranslate"><span class="pre">NULL</span></code>，同时设置 <a class="reference internal" href="../library/exceptions.html#MemoryError" title="MemoryError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">MemoryError</span></code></a> 并返回 <code class="docutils literal notranslate"><span class="pre">-1</span></code>。</p>
</dd></dl>

</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
  <h4>上一个主题</h4>
  <p class="topless"><a href="complex.html"
                        title="上一章">复数对象</a></p>
  <h4>下一个主题</h4>
  <p class="topless"><a href="bytearray.html"
                        title="下一章">字节数组对象</a></p>
  <div role="note" aria-label="source link">
    <h3>本页</h3>
    <ul class="this-page-menu">
      <li><a href="../bugs.html">提交 Bug</a></li>
      <li>
        <a href="https://github.com/python/cpython/blob/3.7/Doc/c-api/bytes.rst"
            rel="nofollow">显示源代码
        </a>
      </li>
    </ul>
  </div>
        </div>
      </div>
      <div class="clearer"></div>
    </div>  
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>导航</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="总目录"
             >索引</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python 模块索引"
             >模块</a> |</li>
        <li class="right" >
          <a href="bytearray.html" title="字节数组对象"
             >下一页</a> |</li>
        <li class="right" >
          <a href="complex.html" title="复数对象"
             >上一页</a> |</li>
        <li><img src="../_static/py.png" alt=""
                 style="vertical-align: middle; margin-top: -1px"/></li>
        <li><a href="https://www.python.org/">Python</a> &#187;</li>
        <li>
          <a href="../index.html">3.7.8 Documentation</a> &#187;
        </li>

          <li class="nav-item nav-item-1"><a href="index.html" >Python/C API 参考手册</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="concrete.html" >具体的对象层</a> &#187;</li>
    <li class="right">
        

    <div class="inline-search" style="display: none" role="search">
        <form class="inline-search" action="../search.html" method="get">
          <input placeholder="快速搜索" type="text" name="q" />
          <input type="submit" value="转向" />
          <input type="hidden" name="check_keywords" value="yes" />
          <input type="hidden" name="area" value="default" />
        </form>
    </div>
    <script type="text/javascript">$('.inline-search').show(0);</script>
         |
    </li>

      </ul>
    </div>  
    <div class="footer">
    &copy; <a href="../copyright.html">版权所有</a> 2001-2020, Python Software Foundation.
    <br />
    Python 软件基金会是一个非盈利组织。
    <a href="https://www.python.org/psf/donations/">请捐助。</a>
    <br />
    最后更新于 6月 29, 2020.
    <a href="../bugs.html">发现了问题</a>？
    <br />
    使用<a href="http://sphinx.pocoo.org/">Sphinx</a>2.3.1 创建。
    </div>

  </body>
</html>